# Works with 3.11 and tested through 3.18
cmake_minimum_required(VERSION 3.11...3.18)

# Project name and a few useful settings. Other commands can pick up the results
project(P2PServer
        VERSION 0.1
        DESCRIPTION "A P2PClient use STUN TURN SDP "
        LANGUAGES CXX)

include_directories(${CMAKE_SOURCE_DIR}/extern)
include_directories(${CMAKE_SOURCE_DIR}/extern/asio)
# Only do these if this is the main project, and not if it is included through add_subdirectory
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)

    # Optionally set things like CMAKE_CXX_STANDARD, CMAKE_POSITION_INDEPENDENT_CODE here
    set(CMAKE_CXX_STANDARD	11)
    set(CMAKE_CXX_STANDARD_REQUIRE )

    # Let's ensure -std=c++xx instead of -std=g++xx
    set(CMAKE_CXX_EXTENSIONS OFF)

    # Let's nicely support folders in IDEs
    set_property(GLOBAL PROPERTY USE_FOLDERS ON)

    # Testing only available if this is the main app
    # Note this needs to be done in the main CMakeLists
    # since it calls enable_testing, which must be in the
    # main CMakeLists.
    #include(CTest)

    # Docs only available if this is the main app
    #find_package(Doxygen)
    #if(Doxygen_FOUND)
     #   add_subdirectory(docs)
    #else()
    #    message(STATUS "Doxygen not found, not building docs")
    #endif()
endif()
MESSAGE(" platform ${CMAKE_SYSTEM}")
if (CMAKE_SYSTEM_NAME MATCHES "Windows")
    message("platform windows, not support sigusr1")
else ()
    add_definitions(-DSUPPORT_SIGUSR1)
endif()

#add_executable(app app.cpp)

# FetchContent added in CMake 3.11, downloads during the configure step
#include(FetchContent)

#FetchContent_Declare(json
#        GIT_REPOSITORY https://gitee.com/taoweitao/nlohmann.git
#        GIT_TAG v3.9.1)
#FetchContent_MakeAvailable(json)

# Accumulator library
# This is header only, so could be replaced with git submodules or FetchContent
#find_package(Boost REQUIRED)
# Adds Boost::boost

# Formatting library
#FetchContent_Declare(
#        fmtlib
#        GIT_REPOSITORY https://github.com/fmtlib/fmt.git
#        GIT_TAG 5.3.0)
#FetchContent_MakeAvailable(fmtlib)
# Adds fmt::fmt

# The compiled library code is here
#add_subdirectory(src)
add_subdirectory(apps)

# The executable code is here

# Testing only available if this is the main app
# Emergency override MODERN_CMAKE_BUILD_TESTING provided as well
#if((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR MODERN_CMAKE_BUILD_TESTING)
#        AND BUILD_TESTING)
#    add_subdirectory(tests)
#endif()
